package castle.defense.project;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;

public class Score {
	
	/*
	 * Class Properties
	 */
	//The score of the player
	public static int score;
	
	//Current multiplier the user has
	public static int multiplier;
	
	//The number of kills the user has acquired
	public static int kills;
	
	//The longest streak of kills the user has acquired without missing an enemy.
	public static int killstreak;
	
	
	private static Paint paint;
	/*
	 * Private variables 
	 */
	private static int longestKS = 0;
	
	public static void initialize() {
		score = 0;
		multiplier = 1;
		kills = 0;
		paint = new Paint();
		paint.setColor(Color.BLACK);
		paint.setTextSize((float)PE.screenPercentX(7.5));
		paint.setTextAlign(Paint.Align.RIGHT);
		paint.setFakeBoldText(true);
	}
	
	public static void draw(Canvas c) {
		GraphicsEngine.drawText(c, String.format("%d", score), (float)PE.sizeX-5, (float)PE.screenPercentX(6.5), paint);
	}
	
	/**
	 * Function to update the user score
	 * @param value:int The value that the enemy unit is worth.
	 */
	public static void incrementScore(int value)
	{
		int inc = value * multiplier;
		if(Options.getDifficulty() == Options.hard) {
			inc = (int)Math.round(1.5*inc);
		} else if (Options.getDifficulty() == Options.easy) {
			inc = (int)Math.round(.75 * inc);
		}
		score += inc;
	}
	
	/**
	 * Function to increment the user's multiplier by one.
	 */
	public static void incMult()
	{
		multiplier++;
	}
	
	/**
	 * Function to reset the user's multiplier if the user missed an enemy unit.
	 */
	public void resetMult()
	{
		multiplier = 1;
	}
	
	/**
	 * Function to increment the user's kill count
	 */
	public static void updateKills()
	{
		kills++;
	}
	
	/**
	 * Function to increment the user's kill streak
	 */
	public static void updateKS()
	{
		//Increments the killstreak counter
		killstreak++;
		
		//Checks to see if the current streak is greater that the longest streak
		//If so, sets the longest streak to the current streak
		if(killstreak > longestKS)
			longestKS = killstreak;
	}
	
	/**
	 * Resets the current killstreak to 0
	 */
	public static void resetKS()
	{
		killstreak = 0;
	}
	
	/**
	 * Function to retrieve the highest killstreak the user has obtained.
	 * @return longestKS:int The longest killstreak the user has obtained.
	 */
	public static int getlongestKS()
	{
		return longestKS;
	}
	
}
